import 'package:get/get.dart';
import 'package:zz_listen_english/common/index.dart';

import '../../common/services/user.dart';

class SplashController extends GetxController {
  SplashController();

  _initData() {
    String firstOpenApp = Storage().getString(Constants.firstOpenApp);
    if (firstOpenApp == "" || firstOpenApp == null) {
      Storage().setString(Constants.ip, "123.56.108.14");
      Storage().setString(Constants.port, "9900");
      Storage().setString(Constants.prefixIp, "http");
      Storage().setString(Constants.firstOpenApp, "1");
    }

    if (UserService.to.hasLogin == false) {
      Future.delayed(const Duration(seconds: 2)).then((_) {
        Get.offAllNamed(RouteNames.login);
      });
    } else {
      Get.offAllNamed(RouteNames.audioPlay);
    }

    update(["splash"]);
  }

  void onTap() {}

  // @override
  // void onInit() {
  //   super.onInit();
  // }

  @override
  void onReady() {
    super.onReady();
    _initData();
  }

// @override
// void onClose() {
//   super.onClose();
// }
}
